﻿using Compass.PlanService.Domain.Entities;
using Compass.Wasm.Shared.Plans;

namespace Compass.PlanService.Domain;
public interface IPlanRepository
{
    //MainPlan
    Task<IQueryable<MainPlan>> GetMainPlansAsync();
    Task<MainPlan?> GetMainPlanByIdAsync(Guid id);
    //扩展MainPlan查询
    Task<MainPlan?> GetMainPlanByNumberAsync(string number);
    Task<IQueryable<MainPlan>> GetMainPlansByProjectIdAsync(Guid projectId);
    Task<MainPlan?> GetMainPlanByProjectIdAndBatchAsync(Guid projectId, int batch);
    Task<List<Guid?>> GetProjectIdsByStatusAsync(MainPlanStatus_e? status);

    double GetDeliveryReliabilityByMonth(int year, int month);
    double GetDeliveryReliabilityByYear(int year);

    //ProductionCycleTime 
    double GetProductionCycleTimeByMonth(int year, int month);
    double GetProductionCycleTimeByYear(int year);
    //FactoryCycleTime
    double GetFactoryCycleTimeByMonth(int year, int month);
    double GetFactoryCycleTimeByYear(int year);
    //OrderCycleTime
    double GetOrderCycleTimeByMonth(int year, int month);
    double GetOrderCycleTimeByYear(int year);

    CycleTimeDto GetCycleTime(int year);

    //Issue
    Task<IQueryable<Issue>> GetIssuesAsync();
    Task<Issue?> GetIssueByIdAsync(Guid id);
    //扩展Issue查询
    Task<IQueryable<Issue>> GetIssuesByMainPlanIdAsync(Guid mainPlanId);
    Task<IQueryable<Guid>> GetMainPlanIdsByOpenIssueAsync();

    //Lesson
    Task<IQueryable<Lesson>> GetLessonsAsync();
    Task<Lesson?> GetLessonByIdAsync(Guid id);
    //扩展Lesson查询
    Task<IQueryable<Lesson>> GetLessonsByMainPlanIdAsync(Guid mainPlanId);
    
    //PackingList
    Task<IQueryable<PackingList>> GetPackingListsAsync();
    Task<PackingList?> GetPackingListByIdAsync(Guid id);
    Task<PackingList?> GetPackingListByOdpNumberAsync(string odpNumber);

    //PackingItem
    Task<IQueryable<PackingItem>> GetPackingItemsAsync();
    Task<PackingItem?> GetPackingItemByIdAsync(Guid id);

    //扩展PackingItem查询
    Task<IQueryable<PackingItem>> GetPackingItemsByMainPlanIdAsync(Guid mainPlanId);
    
    //Pallet
    Task<IQueryable<Pallet>> GetPalletsAsync();
    Task<Pallet?> GetPalletByIdAsync(Guid id);

    //扩展Pallet查询
    Task<Pallet?> GetPalletByPalletNumber(Guid mainPlanId, int palletNumber);
    Task<IQueryable<Pallet>> GetPalletsByMainPlanIdAsync(Guid mainPlanId);
    Task<bool> HavePalletAsync(Guid mainPlanId);
    

    //FinishedGoodsCount
    Task<IQueryable<FinishedGoodsCount>> GetFinishedGoodsCountsAsync();
    Task<FinishedGoodsCount?> GetFinishedGoodsCountByIdAsync(Guid id);
    
}